#pragma once
#include "DXAMLCommon.h"

#include "ArgbPixel.h"

#include "CRasterizerEdgeStore.h"
//class CRasterizerEdgeStore;
class CLayer;
class CBandVectorBuffer;


class CFrameVectorBuffer
{
public: 
	static HRESULT CreateWithFixedSurface(struct IPALSurface * pSurface, XUINT32, XUINT32, XINT32, XINT32, XINT32, XINT32, CFrameVectorBuffer * *);
	virtual ~CFrameVectorBuffer();
	HRESULT AddEdgeStore(CRasterizerEdgeStore * pRasterizerEdgeStore, CLayer * pLayer);
	HRESULT AddEdgeStores(const xvector<xref_ptr<CRasterizerEdgeStore> > & vecEdgeStores, CLayer * pLayer);
	virtual HRESULT RasterizeFrame(enum XSURFTYPE surfaceType, struct ICoreServices * pICoreServices, XBOOL fFullRedraw, XBOOL fEnableDirtyRegionsDisplay, struct XRECT_WH * prcDirtyRect);
	static HRESULT HitTestPath(CRasterizerEdgeStore *, XINT32, XINT32, XINT32, XINT32, XUINT32 *);
	static HRESULT HitTestPath(CRasterizerEdgeStore *, XINT32, XINT32, XUINT32 *);
	XINT32 GetOffsetX();
	XINT32 GetOffsetY();
	virtual XBOOL HasDimensions();
	virtual XINT32 GetWidth();
	virtual XINT32 GetHeight();
	XBOOL IsPrimaryBuffer();
	virtual XBOOL IsEmpty();
	void SetFrameDirty(XBOOL );
	XBOOL IsFrameDirty();
	virtual XBOOL GetIsCached();
	virtual XBOOL IsClearTypeEnabled();
	virtual XINT32 GetRenderedOffsetX();
	virtual XINT32 GetRenderedOffsetY();
	virtual XINT32 GetRenderedWidth();
	virtual XINT32 GetRenderedHeight();
	virtual XINT32 GetMaximumWidth();
	virtual XINT32 GetMaximumHeight();
	virtual HRESULT ResetWithoutRasterize();
	struct IPALSurface * GetRealizationSurface();
	XBOOL HasRealizationSurface();
	XUINT32 GetRealizationSurfaceWidth();
	XUINT32 GetRealizationSurfaceHeight();
	void ReleaseRealizationSurface();
	void OWSetSurface(struct IPALSurface * pSurface, XBOOL fCanFullRedraw);
	void SetFillSurface(struct IPALSurface * pSurface);
	void SetStrokeSurface(struct IPALSurface * pSurface);
	void SetBackgroundColor(struct ArgbPixel);

protected: 
	CFrameVectorBuffer(struct IPALSurface * pOWSurface, 
		XBOOL fRealizationSurfaceIsFixed, 
		XBOOL fForceLocalMemorySurfaces, 
	struct ICoreRenderTarget * pNWRenderTarget, 
		enum PixelFormat pixelFormat, 
	struct ArgbPixel uBackgroundColor, 
		XBOOL fPrimaryBuffer);
	HRESULT Init(XINT32 nOffsetX, XINT32 nOffsetY, XINT32 nWidth, XINT32 nHeight);
	void DestroyBandVectorBuffers();
	virtual void Reset();
	virtual HRESULT AddEdgeStoreInternal(CRasterizerEdgeStore * pRasterizerEdgeStore, XBOOL fEdgeStoreLeaving);
private: 
	static HRESULT CreateCore(struct IPALSurface * pSurface, 
		XUINT32, 
		struct ICoreRenderTarget * pNWRenderTarget, 
		enum PixelFormat pixelFormat, 
		XUINT32, 
		XUINT32, 
		XINT32, 
		XINT32, 
		XINT32, 
		XINT32, 
		CFrameVectorBuffer * *);

	HRESULT EnsureRealizationSurface(enum XSURFTYPE surfaceType, struct ICoreServices * pICoreServices, XUINT32 uWidth, XUINT32 uHeight, XBOOL * pfFullRedraw);
	void InsertPreviousFrameDirtyRects(CBandVectorBuffer * pBandVB, XBOOL fFullRedraw);
	void ReleasePendingPaths();
protected: 
	XINT32 m_nOffsetX;
	XINT32 m_nOffsetY;
	XINT32 m_nWidth;
	XINT32 m_cScanlines;
	XUINT32 m_cNumBands;
	CBandVectorBuffer * * m_pBandVectorBuffer;
private: 
	XUINT32 m_cBandSize;
	XUINT32 m_dwDrawOrder;
	enum PixelFormat m_pixelFormat;
	struct ArgbPixel m_uBackgroundColor;


private: 
	XUINT32 m_fPrimaryBuffer:1;
	XUINT32 m_fFullRedraw:1;
	XUINT32 m_fFrameDirty:1;
	XUINT32 m_fRealizationSurfaceIsFixed:1;
	XUINT32 m_fForceLocalMemorySurfaces:1;
	struct IPALSurface * m_pFillSurface;
	struct IPALSurface * m_pStrokeSurface;


};


